<?php include "../public/header.php";?>
<?php include "../public/header_show.php";?>
<body id="xiangqingPage">
<div id="xiangqingBox">
    <div class="page-title">
        <div class="page-title-con">
            <span class="pageshowtitle">详情</span>
            <div class="page-title-opt-list">
                <?php include "../public_flow/flow_show_optbut.php";?>
                <button class="layui-btn layui-btn-sm btn-light marginr5 opt">
                    操作<i class="layui-icon layui-icon-down layui-font-12"></i>
                </button>
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
    <div class="main-container">
        <div><?php include "../public_flow/flow_show_info.php";?></div>
        <div class="tongbox tongbox5">
            <div class="tuo"><div class="tit">项目名称</div><div class="con" id="tong_enginname"></div></div>
            <div class="tuo"><div class="tit">合同类型</div><div class="con" id="tong_caitype_name"></div></div>
            <div class="tuo"><div class="tit">合同属性</div><div class="con" id="tong_caishu"></div></div>
            <div class="tuo"><div class="tit">合同金额(元)</div><div class="con" id="tong_money"></div></div>
            <div class="tuo"><div class="tit">供应方(乙方)</div><div class="con" id="tong_gonger"></div></div>
        </div>
        <div class="table-box tablenes">
            <div class="title">项目信息</div>
            <table class="layui-table">
                <tbody>
                <tr><td class="tt">项目名称</td><td class="tv colorlan" id="enginid_name" colspan="3"></td></tr>
                </tbody>
            </table>
        </div>

        <div class="table-box tablenes">
            <div class="title">支出合同信息</div>
            <table class="layui-table">
                <tbody>
                <tr><td class="tt">合同名称</td><td id="name" class="tv"></td><td class="tt">合同编号</td><td id="number" class="tv"></td></tr>
                <tr><td class="tt">合同类型</td><td id="caitype_name" class="tv"></td><td class="tt">合同年份</td><td id="year" class="tv"></td></tr>
                <tr><td class="tt">合同属性</td><td class="tv" id="caishu" colspan="3"></td></tr>
                <tr><td class="tt">采购方(甲方)</td><td id="caier_name" class="tv"></td><td class="tt">供应方(乙方)</td><td id="gonger" class="tv"></td></tr>
                <tr><td class="tt">合同金额(元)</td><td id="money" class="tv"></td><td class="tt">税率(%)</td><td id="rate" class="tv"></td></tr>
                <tr><td class="tt">合同开始日期</td><td id="startdt" class="tv"></td><td class="tt">合同结束日期</td><td id="enddt" class="tv"></td></tr>
                <tr><td class="tt">合同状态</td><td id="state" class="tv"></td><td class="tt">签订日期</td><td id="qiandt" class="tv"></td></tr>
                <tr><td class="tt">合同份数</td><td class="tv" id="henum" colspan="3"></td></tr>
                <tr><td class="tt">主要条款</td><td class="tv" id="clause" colspan="3"></td></tr>
                <tr><td class="tt">备注</td><td class="tv" id="explain" colspan="3"></td></tr>
                </tbody>
            </table>
        </div>

        <div><?php include "../public/upinfo_show.php";?></div>

        <div><?php include "../public_flow/flow_show_flowrelas.php";?></div>

        <div class="table-box tablenes">
            <script type="text/html" id="toolbarDemo_bian">合同变更</script>
            <div class="tableShow">
                <table id="datalist_bian" lay-filter="datalist_bian"></table>
            </div>
        </div>

        <div class="table-box tablenes">
            <script type="text/html" id="toolbarDemo">
                <span>合同明细</span>
                <span class="colorhong layui-hide" id="havebudget">（红色数值表示已超出当前预算值，请谨慎审核！）</span>
            </script>
            <div class="tableShow">
                <table id="datalist" lay-filter="datalist"></table>
            </div>
        </div>

        <div><?php include '../public_flow/flow_show_shenlog.php'?></div>
        <div><?php include '../public_flow/flow_show_talk.php'?></div>
        <div><?php include '../public/opt_browse.php'?></div>
    </div>

    <div class="showrrboxtext">
        <div class="table-box tablenes">
            <div class="title">本合同信息</div>
            <div class="tuo"><div class="tit">合同变更金额(元)</div><div class="con" id="right_bianfee">0</div></div>
            <div class="tuo"><div class="tit">合同金额含变更(元)</div><div class="con" id="right_money">0</div></div>
        </div>
        <div class="table-box tablenes">
            <div class="title">本合同结算</div>
            <div class="tuo"><div class="tit">合同结算金额(元)</div><div class="con" id="right_caijiemoney">0</div></div>
            <div class="tuo"><div class="tit">结算扣罚款金额(元)</div><div class="con" id="right_caijiekoufafee">0</div></div>
            <div class="tuo"><div class="tit">合同结算净额(元)</div><div class="con" id="right_caijiejingfee">0</div></div>
        </div>
        <div class="table-box tablenes">
            <div class="title">本合同票/款</div>
            <div class="tuo"><div class="tit">合同付款金额(元)</div><div class="con" id="right_zhixiangfee">0</div></div>
            <div class="tuo"><div class="tit">合同收票金额(元)</div><div class="con" id="right_piaoshoufee">0</div></div>
            <div class="tuo"><div class="tit">结算待付款(元)</div><div class="con" id="right_jiedaifee">0</div></div>
        </div>
        <div class="table-box tablenes caitype_cai layui-hide">
            <div class="title">本合同入库</div>
            <div class="tuo"><div class="tit">合同入库金额(元)</div><div class="con" id="right_stuffrufee">0</div></div>
        </div>
    </div>
    <div><?php include '../public/shrrbox.php'?></div>
</div>
<script>
    var param_id = getQueryVariable('id') || 0;

    layui.use(['form', 'layer', "laytp",'element','dropdown','laypage','table','soulTable'], function() {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable,element = layui.element;

        facade.ajax({url: ask_contract_cai_show, data:{id: param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                var engininfo = res.data.engininfo;
                $("#flowdingname").text(data.name);

                if(engininfo){
                    $("#tong_enginname").text(engininfo.name);
                }
                $("#tong_caitype_name").text(data.caitype_name);
                $("#tong_caishu").text(data.caishu);
                $("#tong_money").text(parseFormatNum(data.money));
                $("#tong_gonger").text(data.gonger);


                $("#right_bianfee").text(parseFormatNum(data.bianfee)).addClass('colorlan').click(function () {
                    openNavPage('查看支出合同变更信息','contract_bian/index.php?status=1&id='+data.id);
                });
                $("#right_money").text(parseFormatNum(data.money));
                $("#right_caijiemoney").text(parseFormatNum(data.caijiemoney)).addClass('colorlan').click(function () {
                    openNavPage('查看支出合同结算信息','contract_cai_jie/index.php?status=1&isreal=1&caiid='+data.id);
                });
                $("#right_caijiekoufafee").text(parseFormatNum(data.caijiekoufafee)).addClass('colorlan').click(function () {
                    openNavPage('查看支出合同结算信息','contract_cai_jie/index.php?status=1&isreal=1&caiid='+data.id);
                });
                $("#right_caijiejingfee").text(parseFormatNum(data.caijiejingfee)).addClass('colorlan').click(function () {
                    openNavPage('查看支出合同结算信息','contract_cai_jie/index.php?status=1&isreal=1&caiid='+data.id);
                });
                $("#right_zhixiangfee").text(parseFormatNum(data.zhixiangfee));
                $("#right_piaoshoufee").text(parseFormatNum(data.piaoshoufee)).addClass('colorlan').click(function () {
                    openNavPage('查看项目收票明细信息','piao_shou/detail.php?status=1&caiid='+data.id);
                });
                $("#right_jiedaifee").text(parseFormatNum(data.jiedaifee));
                if(data.jiedaifee < 0){
                    $("#right_jiedaifee").addClass('colorhong');
                }
                if(data.caitype == 'cai'){
                    $(".caitype_cai").removeClass('layui-hide');
                    $("#right_stuffrufee").text(parseFormatNum(data.stuffrufee)).addClass('colorlan').click(function () {
                        openNavPage('查看材料入库信息','stuff_ru/index.php?status=1&rutype=1&caiid='+data.id);
                    });
                }











                if(engininfo){
                    $("#enginid_name").text(engininfo.name).click(function () {
                        openPage('../engin/show.php?id='+engininfo.id);
                    });
                }


                $("#name").text(data.name);
                $("#number").text(data.number);
                $("#caitype_name").text(data.caitype_name);
                $("#year").text(data.year);
                $("#caishu").text(data.caishu);
                $("#caier_name").text(data.caier_name);
                $("#gonger").text(data.gonger);
                $("#money").text(showChineseNumber(data.money));
                $("#rate").text(data.rate);
                $("#startdt").text(data.startdt);
                $("#enddt").text(data.enddt);
                $("#state").text(data.state);
                $("#henum").text(data.henum);
                $("#qiandt").text(data.qiandt);
                $("#clause").text(data.clause);
                $("#explain").text(data.explain);




                var mytableList = table.render({
                    elem: "#datalist_bian",data:res.data.bian, toolbar: '#toolbarDemo_bian', page: false
                    ,limit:TabInitShow.limit,soulSort: TabInitShow.soulSort,method: TabInitShow.method, overflow: TabInitShow.overflow
                    ,defaultToolbar: TabInitShow.defaultToolbar,filter: TabInitShow.filter ,text: TabInitShow.text
                    ,request: TabInitShow.request,response: TabInitShow.response,contextmenu:get_table_contextmenu(soulTable)
                    , cols: [[
                        {type:'numbers',title:'序号',fixed:'left'}
                        ,{field:'',title:'流程状态',templet: function(d){
                                if(d.billid > 0){
                                    if(d.status == 0){
                                        return '<span class="list_billid colorlan" onclick="openPage(\'../contract_bian/show.php?id='+d.id+'\');">流程(审批中)</span>'
                                    }else if(d.status == 1){
                                        return '<span class="list_billid colorlan" onclick="openPage(\'../contract_bian/show.php?id='+d.id+'\');">流程(审批通过)</span>'
                                    }else{
                                        return '';
                                    }
                                }else{
                                    return '<td>手动</td>';
                                }
                            }}
                        ,{field:'number',title:'变更单号',templet: function(d){
                                return '<span class="colorlan" onclick="show_contractbian('+d.id+')">'+d.number+'</span>';
                            }}
                        ,{field: 'bianfee', title: '本次变更金额(元)'}
                        ,{field: 'dt', title: '变更日期'}


                    ]]
                    , done: function (res) {
                        soulTable.render(this);
                    }
                });



                var yusuan_hide = false;
                if(!data.is_budget){
                    yusuan_hide = true;
                }

                var mytableList22 = table.render({
                    elem: "#datalist",data:res.data.list, toolbar: '#toolbarDemo', page: false
                    ,limit:TabInitShow.limit,soulSort: TabInitShow.soulSort,method: TabInitShow.method, overflow: TabInitShow.overflow
                    ,defaultToolbar: TabInitShow.defaultToolbar,filter: TabInitShow.filter ,text: TabInitShow.text
                    ,request: TabInitShow.request,response: TabInitShow.response,contextmenu:get_table_contextmenu(soulTable)
                    , cols: [[
                        {type:'numbers',title:'序号',fixed:'left'}
                        ,{field:'listid_name',title:'预算项',hide:yusuan_hide,templet: function(d){
                                return '<span class="colorlan" onclick="openNavPage(\'查看预算明细信息\',\'engin_budget/detail.php?listid='+d.listid+'\')">'+d.listid_name+'</span>';
                            }}
                        ,{field: 'name', title: '名称及规格'}
                        ,{field: 'unit', title: '单位'}
                        ,{field:'',title:'数量',templet: function(d){
                            if(data.is_budget && d.chao_num){
                                return '<span class="colorhong">'+d.num+'<span>';
                            }else{
                                return d.num;
                            }
                        }}
                        ,{field: 'price', title: '单价(元)',align:'right',templet: function(d){return parseFormatNum(d.price);}}
                        ,{field:'',title:'金额(元)',align:'right',templet: function(d){
                                if(data.is_budget && d.chao_money){
                                    return '<span class="colorhong">'+parseFormatNum(d.money)+'<span>';
                                }else{
                                    return parseFormatNum(d.money);
                                }
                            }}
                        ,{field: 'explain', title: '备注'}

                    ]]
                    , done: function (res) {
                        soulTable.render(this);

                        if(data.is_budget){
                            $("#havebudget").removeClass('layui-hide');
                        }
                    }
                });


                public_flow_show_display(res.data.billinfo);
                public_upload_show_file('upload_files', res.data.files);
                render_from();
            }
        });

        public_get_readsandlog('contract_cai', param_id);
    });

    function show_contractbian(id) {
        openPage('../contract_bian/show.php?id='+id);
    }

    function show_contractyusuan(listid) {
        openPage('bglist.php?listid='+listid);
    }



</script>
</body>
</html>




